home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-4.0 / gdb / gdb.info-1 < prev    next >
Encoding:
Text File  |  1991-08-24  |  48.5 KB  |  1,341 lines

  1. Info file gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texi.
  3.  
  4.    This file documents the GNU debugger GDB.
  5.  
  6.    Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this
  15. manual under the conditions for verbatim copying, provided also that
  16. the section entitled "GNU General Public License" is included
  17. exactly as in the original, and provided that the entire resulting
  18. derived work is distributed under the terms of a permission notice
  19. identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for
  23. modified versions, except that the section entitled "GNU General
  24. Public License" may be included in a translation approved by the
  25. Free Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gdb.info,  Node: Top,  Next: Summary,  Prev: (dir),  Up: (dir)
  29.  
  30.    This file describes version 4.0 of GDB, the GNU symbolic debugger.
  31.  
  32. * Menu:
  33.  
  34. * Summary::                     Summary of GDB
  35. * New Features::                New Features in GDB version 4.0
  36. * Sample Session::              A Sample GDB Session
  37. * Invocation::                  Getting In and Out of GDB
  38. * Commands::                    
  39. * Running::                     Running Programs Under GDB
  40. * Stopping::                    Stopping and Continuing
  41. * Stack::                       Examining the Stack
  42. * Source::                      Examining Source Files
  43. * Data::                        Examining Data
  44. * Cplusplus::                   C++ and GDB
  45. * Symbols::                     Examining the Symbol Table
  46. * Altering::                    Altering Execution
  47. * GDB Files::               
  48. * Targets::                     Specifying a Debugging Target 
  49. * Controlling GDB::         Controlling GDB
  50. * Sequences::                   Canned Sequences of Commands
  51. * Emacs::                       Using GDB under GNU Emacs
  52. * GDB Bugs::                        Reporting Bugs in GDB
  53. * Renamed Commands::            
  54. * Installing GDB::          Installing GDB
  55. * Copying::                     GNU GENERAL PUBLIC LICENSE
  56. * Index::                       Index
  57.  -- The Detailed Node Listing --
  58.  
  59. Summary of GDB
  60.  
  61. * Free Software::               Free Software
  62. * Contributors::                Contributors to GDB
  63.  
  64. Getting In and Out of GDB
  65.  
  66. * Starting GDB::            Starting GDB
  67. * Leaving GDB::                     Leaving GDB
  68. * Shell Commands::              Shell Commands
  69.  
  70. Starting GDB
  71.  
  72. * File Options::                Choosing Files
  73. * Mode Options::                Choosing Modes
  74.  
  75. GDB Commands
  76.  
  77. * Command Syntax::              Command Syntax
  78. * Help::                        Getting Help
  79.  
  80. Running Programs Under GDB
  81.  
  82. * Compilation::                 Compiling for Debugging
  83. * Starting::                    Starting your Program
  84. * Arguments::                   Your Program's Arguments
  85. * Environment::                 Your Program's Environment
  86. * Working Directory::           Your Program's Working Directory
  87. * Input/Output::                Your Program's Input and Output
  88. * Attach::                      Debugging an Already-Running Process
  89. * Kill Process::                Killing the Child Process
  90.  
  91. Stopping and Continuing
  92.  
  93. * Breakpoints::                 Breakpoints, Watchpoints, and Exceptions
  94. * Continuing and Stepping::     Resuming Execution
  95. * Signals::                     Signals
  96.  
  97. Breakpoints, Watchpoints, and Exceptions
  98.  
  99. * Set Breaks::                  Setting Breakpoints
  100. * Set Watchpoints::             Setting Watchpoints
  101. * Exception Handling::          Breakpoints and Exceptions
  102. * Delete Breaks::               Deleting Breakpoints
  103. * Disabling::                   Disabling Breakpoints
  104. * Conditions::                  Break Conditions
  105. * Break Commands::              Breakpoint Command Lists
  106. * Breakpoint Menus::            Breakpoint Menus
  107. * Error in Breakpoints::        
  108.  
  109. Examining the Stack
  110.  
  111. * Frames::                      Stack Frames
  112. * Backtrace::                   Backtraces
  113. * Selection::                   Selecting a Frame
  114. * Frame Info::                  Information on a Frame
  115.  
  116. Examining Source Files
  117.  
  118. * List::                        Printing Source Lines
  119. * Search::                      Searching Source Files
  120. * Source Path::                 Specifying Source Directories
  121. * Machine Code::                Source and Machine Code
  122.  
  123. Examining Data
  124.  
  125. * Expressions::                 Expressions
  126. * Variables::                   Program Variables
  127. * Arrays::                      Artificial Arrays
  128. * Output formats::              Output formats
  129. * Memory::                      Examining Memory
  130. * Auto Display::                Automatic Display
  131. * Print Settings::              Print Settings
  132. * Value History::               Value History
  133. * Convenience Vars::            Convenience Variables
  134. * Registers::                   Registers
  135. * Floating Point Hardware::     Floating Point Hardware
  136.  
  137. Altering Execution
  138.  
  139. * Assignment::                  Assignment to Variables
  140. * Jumping::                     Continuing at a Different Address
  141. * Signaling::                   Giving the Program a Signal
  142. * Returning::                   Returning from a Function
  143. * Calling::                     Calling your Program's Functions
  144.  
  145. GDB's Files
  146.  
  147. * Files::                       Commands to Specify Files
  148. * Symbol Errors::               Errors Reading Symbol Files
  149.  
  150. Specifying a Debugging Target 
  151.  
  152. * Active Targets::              Active Targets
  153. * Target Commands::             Commands for Managing Targets
  154. * Remote::                      Remote Debugging
  155.  
  156. Remote Debugging
  157.  
  158. * i960-Nindy Remote::           
  159. * EB29K Remote::                
  160. * VxWorks Remote::              
  161.  
  162. GDB with a Remote i960 (Nindy)
  163.  
  164. * Nindy Startup::               Startup with Nindy
  165. * Nindy Options::               Options for Nindy
  166. * Nindy reset::                 Nindy Reset Command
  167.  
  168. GDB with a Remote EB29K
  169.  
  170. * Comms (EB29K)::               Communications Setup
  171. * gdb-EB29K::                   EB29K cross-debugging
  172. * Remote Log::                  Remote Log
  173.  
  174. GDB and VxWorks
  175.  
  176. * VxWorks connection::          Connecting to VxWorks
  177. * VxWorks download::            VxWorks Download
  178. * VxWorks attach::              Running Tasks
  179.  
  180. Controlling GDB
  181.  
  182. * Prompt::                      Prompt
  183. * Editing::                     Command Editing
  184. * History::                     Command History
  185. * Screen Size::                 Screen Size
  186. * Numbers::                     Numbers
  187. * Messages/Warnings::           Optional Warnings and Messages
  188.  
  189. Canned Sequences of Commands
  190.  
  191. * Define::                      User-Defined Commands
  192. * Command Files::               Command Files
  193. * Output::                      Commands for Controlled Output
  194.  
  195. Reporting Bugs in GDB
  196.  
  197. * Bug Criteria::                Have You Found a Bug?
  198. * Bug Reporting::               How to Report Bugs
  199.  
  200. 
  201. File: gdb.info,  Node: Summary,  Next: New Features,  Prev: Top,  Up: Top
  202.  
  203. Summary of GDB
  204. **************
  205.  
  206.    The purpose of a debugger such as GDB is to allow you to see what
  207. is going on "inside" another program while it executes--or what
  208. another program was doing at the moment it crashed.
  209.  
  210.    GDB can do four main kinds of things (plus other things in support
  211. of these) to help you catch bugs in the act:
  212.  
  213.    * Start your program, specifying anything that might affect its
  214.      behavior.
  215.  
  216.    * Make your program stop on specified conditions.
  217.  
  218.    * Examine what has happened, when your program has stopped.
  219.  
  220.    * Change things in your program, so you can experiment with
  221.      correcting the effects of one bug and go on to learn about
  222.      another.
  223.  
  224.    You can use GDB to debug programs written in C and C++.  Modula-2
  225. support is being implemented, and Fortran support will be added when
  226. a GNU Fortran compiler is ready.
  227.  
  228. * Menu:
  229.  
  230. * Free Software::               Free Software
  231. * Contributors::                Contributors to GDB
  232.  
  233. 
  234. File: gdb.info,  Node: Free Software,  Next: Contributors,  Prev: Summary,  Up: Summary
  235.  
  236. Free Software
  237. =============
  238.  
  239.    GDB is "free software", protected by the GNU General Public
  240. License (GPL).  The GPL gives you the freedom to copy or adapt a
  241. licensed program--but every person getting a copy also gets with it
  242. the freedom to modify that copy (which means that they must get
  243. access to the source code), and the freedom to distribute further
  244. copies.  Typical software companies use copyrights to limit your
  245. freedoms; the Free Software Foundation uses the GPL to preserve
  246. these freedoms.
  247.  
  248.    Fundamentally, the General Public License is a license which says
  249. that you have these freedoms and that you can't take these freedoms
  250. away from anyone else.
  251.  
  252.    For full details, *note Copying::..
  253.  
  254. 
  255. File: gdb.info,  Node: Contributors,  Prev: Free Software,  Up: Summary
  256.  
  257. Contributors to GDB
  258. ===================
  259.  
  260.    Richard Stallman was the original author of GDB, and of many other
  261. GNU programs.  Many others have contributed to its development. 
  262. This section attempts to credit major contributors.  One of the
  263. virtues of free software is that everyone is free to contribute to
  264. it; with regret, we cannot actually acknowledge everyone here.  The
  265. file `ChangeLog' in the GDB distribution approximates a blow-by-blow
  266. account.
  267.  
  268.    Changes much prior to version 2.0 are lost in the mists of time.
  269.  
  270.      *Plea:* Additions to this section are particularly welcome.  If
  271.      you or your friends (or enemies; let's be evenhanded) have been
  272.      unfairly omitted from this list, we would like to add your names!
  273.  
  274.    So that they may not regard their long labor as thankless, we
  275. particularly thank those who shepherded GDB through major releases:
  276. John Gilmore (release 4.0; happy birthday, John!); Jim Kingdon
  277. (releases 3.9, 3.5, 3.4, 3.3); and Randy Smith (releases 3.2, 3.1,
  278. 3.0).  As major maintainer of GDB for some period, each contributed
  279. significantly
  280. to the structure, stability, and capabilities of the entire debugger.
  281.  
  282.    Richard Stallman, assisted at various times by Pete TerMaat, Chris
  283. Hanson, and Richard Mlynarik, handled releases through 2.8.
  284.  
  285.    Michael Tiemann is the author of most of the GNU C++ support in
  286. GDB, with significant additional contributions from Per Bothner. 
  287. James Clark wrote the GNU C++ demangler.  Early work on C++ was by
  288. Peter TerMaat (who also did much general update work leading to
  289. release 3.0).
  290.  
  291.    GDB 4.0 uses the BFD subroutine library to examine multiple
  292. object-file formats; BFD was a joint project of V. Gumby
  293. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
  294.  
  295.    David Johnson wrote the original COFF support; Pace Willison did
  296. the original support for encapsulated COFF.
  297.  
  298.    Adam de Boor and Bradley Davis contributed the ISI Optimum V
  299. support.  Per Bothner, Noboyuki Hikichi, and Alessandro Forin
  300. contributed MIPS support.  Jean-Daniel Fekete contributed Sun 386i
  301. support.  Chris Hanson improved the HP9000 support.  Noboyuki
  302. Hikichi
  303. and Tomoyuki Hasei contributed Sony/News OS 3 support.  David
  304. Johnson contributed Encore Umax support.  Jyrki Kuoppala contributed
  305. Altos 3068 support.  Keith Packard contributed NS32K support.  Doug
  306. Rabson contributed Acorn Risc Machine support.  Chris Smith
  307. contributed
  308. Convex support (and Fortran debugging).  Jonathan Stone contributed
  309. Pyramid support.  Michael Tiemann contributed SPARC support.  Tim
  310. Tucker contributed support for the Gould NP1 and Gould Powernode. 
  311. Pace Willison contributed Intel 386 support.  Jay Vosburgh
  312. contributed Symmetry support.
  313.  
  314.    Rich Schaefer helped with support of SunOS shared libraries.
  315.  
  316.    Jay Fenlason and Roland McGrath ensured that GDB and GAS agree
  317. about several machine instruction sets.
  318.  
  319.    Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
  320. develop remote debugging.  Intel Corporation and Wind River Systems
  321. contributed remote debugging modules for their products.
  322.  
  323.    Brian Fox is the author of the readline libraries providing
  324. command-line editing and command history.
  325.  
  326. 
  327. File: gdb.info,  Node: New Features,  Next: Sample Session,  Prev: Summary,  Up: Top
  328.  
  329. New Features since GDB version 3.5
  330. **********************************
  331.  
  332. *Targets*
  333.      Using the new command `target', you can select at runtime
  334.      whether you are debugging local files, local processes,
  335.      standalone systems over a serial port, realtime systems over a
  336.      TCP/IP connection, etc.  The command `load' can download
  337.      programs into a remote system.  Serial stubs are available for
  338.      Motorola 680x0 and Intel 80386 remote systems; GDB also
  339.      supports debugging realtime processes running under VxWorks,
  340.      using SunRPC Remote Procedure Calls over TCP/IP to talk to a
  341.      debugger stub on the target system.  Internally, GDB now uses a
  342.      function vector to mediate access to different targets; if you
  343.      need to add your own support for a remote protocol, this makes
  344.      it much easier.
  345.  
  346. *Watchpoints*
  347.      GDB now sports watchpoints as well as breakpoints.  You can use
  348.      a watchpoint to stop execution whenever the value of an
  349.      expression changes, without having to predict a particular
  350.      place in your program where this may happen.
  351.  
  352. *Wide Output*
  353.      Commands that issue wide output now insert newlines at places
  354.      designed to make the output more readable.
  355.  
  356. *Object Code Formats*
  357.      GDB uses a new library called the Binary File Descriptor (BFD)
  358.      Library to permit it to switch dynamically, without
  359.      reconfiguration or recompilation, between different object-file
  360.      formats.  Formats currently supported are COFF, a.out, and the
  361.      Intel 960 b.out; files may be read as .o's, archive libraries,
  362.      or core dumps.  BFD is available as a subroutine library so
  363.      that other programs may take advantage of it, and the other GNU
  364.      binary utilities are being converted to use it.
  365.  
  366. *Configuration and Ports*
  367.      Compile-time configuration (to select a particular architecture
  368.      and operating system) is much easier.  The script `configure'
  369.      now allows you to configure GDB as either a native debugger or
  370.      a cross-debugger. *Note Installing GDB:: for details on how to
  371.      configure and on what architectures are now available.
  372.  
  373. *Interaction*
  374.      The user interface to GDB's control variables has been
  375.      simplified and consolidated in two commands, `set' and `show'. 
  376.     
  377.      Output lines are now broken at readable places, rather than
  378.      overflowing onto the next line.  You can suppress output of
  379.      machine-level addresses, displaying only source language
  380.      information.
  381.  
  382. *C++*
  383.      GDB now supports C++ multiple inheritance (if used with a GCC
  384.      version 2 compiler), and also has limited support for C++
  385.      exception handling, with the commands `catch' and `info catch':
  386.      GDB can break when an exception is raised, before the stack is
  387.      peeled back to the exception handler's context.
  388.  
  389. *Command Rationalization*
  390.      Many GDB commands have been renamed to make them easier to
  391.      remember and use.  In particular, the subcommands of `info' and
  392.      `show'/`set' are grouped to make the former refer to the state
  393.      of your program, and the latter refer to the state of GDB itself.
  394.      *Note Renamed Commands::, for details on what commands were
  395.      renamed.
  396.  
  397. *Shared Libraries*
  398.      GDB 4.0 can debug programs and core files that use SunOS shared
  399.      libraries.  You can load symbols from a shared library with the
  400.      command `sharedlibrary' (*note Files::.).
  401.  
  402. *Reference Card*
  403.      GDB 4.0 has a reference card; *Note Formatting Manual:: for
  404.      instructions on printing it.
  405.  
  406. *Work in Progress*
  407.      Kernel debugging for BSD and Mach systems; Tahoe and HPPA
  408.      architecture support.
  409.  
  410. 
  411. File: gdb.info,  Node: Sample Session,  Next: Invocation,  Prev: New Features,  Up: Top
  412.  
  413. A Sample GDB Session
  414. ********************
  415.  
  416.    You can use this manual at your leisure to read all about GDB. 
  417. However, a handful of commands are enough to get started using the
  418. debugger.
  419. This chapter illustrates these commands.
  420.  
  421.    One of the preliminary versions of GNU `m4' (a generic macro
  422. processor) exhibits the following bug: sometimes, when we change its
  423. quote strings from the default, the commands used to capture one
  424. macro's definition in another stop working.  In the following short
  425. `m4' session, we define a macro `foo' which expands to `0000'; we
  426. then
  427. use the `m4' builtin `defn' to define `bar' as the same thing. 
  428. However, when we change the open quote string to `<QUOTE>' and the
  429. close quote string to `<UNQUOTE>', the same procedure fails to
  430. define a new synonym `baz':
  431.  
  432.      $ cd gnu/m4
  433.      $ ./m4
  434.      define(foo,0000)
  435.      
  436.      foo
  437.      0000
  438.      define(bar,defn(`foo'))
  439.      
  440.      bar
  441.      0000
  442.      changequote(<QUOTE>,<UNQUOTE>)
  443.      
  444.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  445.      baz
  446.      C-d
  447.      m4: End of input: 0: fatal error: EOF in string
  448.  
  449. Let's use GDB to try to see what's going on.
  450.  
  451.      $ gdb m4
  452.      Reading symbol data from m4...done.
  453.      (gdb)
  454.  
  455. GDB reads only enough symbol data to know where to find the rest when
  456. needed;
  457. as a result, the first prompt comes up very quickly.  We then tell
  458. GDB to use a narrower display width than usual, so that examples
  459. will fit in this manual.
  460.  
  461.      (gdb) set width 70
  462.  
  463. Let's see how the `m4' builtin `changequote' works.  Having looked at
  464. the source, we know the relevant subroutine is `m4_changequote', so
  465. we set a breakpoint there with GDB's `break' command.
  466.  
  467.      (gdb) break m4_changequote
  468.      Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  469.  
  470. Using the `run' command, we start `m4' running under GDB control; as
  471. long as control does not reach the `m4_changequote' subroutine, the
  472. program runs as usual:
  473.  
  474.      (gdb) run
  475.      Starting program: /work/Editorial/gdb/gnu/m4/m4 
  476.      define(foo,0000)
  477.      
  478.      foo
  479.      0000
  480.  
  481. To trigger the breakpoint, we call `changequote'.  GDB suspends
  482. execution of `m4', displaying information about the context where it
  483. stops.
  484.  
  485.      changequote(<QUOTE>,<UNQUOTE>)
  486.      
  487.      Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879
  488.      879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
  489.  
  490. Now we use the command `n' (`next') to advance execution to the next
  491. line of the current function.
  492.  
  493.      (gdb) n
  494.      882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil,
  495.  
  496. `set_quotes' looks like a promising subroutine.  We can go into it by
  497. using the command `s' (`step') instead of `next'.  `step' goes to
  498. the next line to be executed in *any* subroutine, so it steps into
  499. `set_quotes'.
  500.  
  501.      (gdb) s
  502.      set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  503.          at input.c:530
  504.      530         if (lquote != def_lquote)
  505.  
  506. The summary display showing the subroutine where `m4' is now
  507. suspended (and its arguments) is called a stack frame display.  We
  508. can use the `backtrace' command (which can also be spelled `bt'), to
  509. see where we are in the stack: it displays a stack frame for each
  510. active subroutine.
  511.  
  512.      (gdb) bt
  513.      #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  514.          at input.c:530
  515.      #1  0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882
  516.      #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  517.      #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  518.          at macro.c:71
  519.      #4  0x79dc in expand_input () at macro.c:40
  520.      #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  521.  
  522. Let's step through a few more lines to see what happens.  The first
  523. two times, we can use `s'; the next two times we use `n' to avoid
  524. falling into the `xstrdup' subroutine.
  525.  
  526.      (gdb) s
  527.      0x3b5c  532         if (rquote != def_rquote)
  528.      (gdb) s
  529.      0x3b80  535         lquote = (lq == nil || *lq == '\0') ? def_lquote :\
  530.       xstrdup(lq);
  531.      (gdb) n
  532.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
  533.      (rq);
  534.      (gdb) n
  535.      538         len_lquote = strlen(rquote);
  536.  
  537. The last line displayed looks a little odd; let's examine the
  538. variables `lquote' and `rquote' to see if they are in fact the new
  539. left and right quotes we specified.  We can use the command `p'
  540. (`print') to see their values.
  541.  
  542.      (gdb) p lquote
  543.      $1 = 0x35d40 "<QUOTE>"
  544.      (gdb) p rquote
  545.      $2 = 0x35d50 "<UNQUOTE>"
  546.  
  547. `lquote' and `rquote' are indeed the new left and right quotes. 
  548. Let's look at some context; we can display ten lines of source
  549. surrounding the current line, with the `l' (`list') command.
  550.  
  551.      (gdb) l
  552.      533             xfree(rquote);
  553.      534     
  554.      535         lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\
  555.      (lq);
  556.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
  557.      (rq);
  558.      537     
  559.      538         len_lquote = strlen(rquote);
  560.      539         len_rquote = strlen(lquote);
  561.      540     }
  562.      541     
  563.      542     void
  564.  
  565. Let's step past the two lines that set `len_lquote' and `len_rquote',
  566. and then examine the values of those variables.
  567.  
  568.      (gdb) n
  569.      539         len_rquote = strlen(lquote);
  570.      (gdb) n
  571.      540     }
  572.      (gdb) p len_lquote
  573.      $3 = 9
  574.      (gdb) p len_rquote
  575.      $4 = 7
  576.  
  577. That certainly looks wrong, assuming `len_lquote' and `len_rquote'
  578. are
  579. meant to be the lengths of `lquote' and `rquote' respectively. 
  580. Let's try setting them to better values.  We can use the `p' command
  581. for this, since it'll print the value of any expression--and that
  582. expression can include subroutine calls and assignments.
  583.  
  584.      (gdb) p len_lquote=strlen(lquote)
  585.      $5 = 7
  586.      (gdb) p len_rquote=strlen(rquote)
  587.      $6 = 9
  588.  
  589. Let's see if that fixes the problem of using the new quotes with the
  590. `m4' built-in `defn'.  We can allow `m4' to continue executing with
  591. the `c' (`continue') command, and then try the example that caused
  592. trouble initially:
  593.  
  594.      (gdb) c
  595.      Continuing.
  596.      
  597.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  598.      
  599.      baz
  600.      0000
  601.  
  602. Success!  The new quotes now work just as well as the default ones. 
  603. The problem seems to have been just the two typos defining the wrong
  604. lengths.  We'll let `m4' exit by giving it an EOF as input.
  605.  
  606.      C-d
  607.      Program exited normally.
  608.  
  609. The message `Program exited normally.' is from GDB; it indicates `m4'
  610. has finished executing.  We can end our GDB session with the GDB
  611. `quit' command.
  612.  
  613.      (gdb) quit
  614.  
  615. 
  616. File: gdb.info,  Node: Invocation,  Next: Commands,  Prev: Sample Session,  Up: Top
  617.  
  618. Getting In and Out of GDB
  619. *************************
  620.  
  621. * Menu:
  622.  
  623. * Starting GDB::            Starting GDB
  624. * Leaving GDB::                     Leaving GDB
  625. * Shell Commands::              Shell Commands
  626.  
  627. 
  628. File: gdb.info,  Node: Starting GDB,  Next: Leaving GDB,  Prev: Invocation,  Up: Invocation
  629.  
  630. Starting GDB
  631. ============
  632.  
  633.    GDB is invoked with the shell command `gdb'.  Once started, it
  634. reads commands from the terminal until you tell it to exit.
  635.  
  636.    You can run `gdb' with no arguments or options; but the most usual
  637. way to start GDB is with one argument or two, specifying an
  638. executable program as the argument:
  639.  
  640.      gdb program
  641.  
  642. You can also start with both an executable program and a core file
  643. specified:
  644.  
  645.      gdb program core
  646.  
  647.    You can, instead, specify a process ID as a second argument, if
  648. you want to debug a running process:
  649.  
  650.      gdb program 1234
  651.  
  652. would attach GDB to process `1234' (unless you also have a file named
  653. `1234'; GDB does check for a core file first).
  654.  
  655. You can further control how GDB starts up by using command-line
  656. options.  GDB itself can remind you of the options available:
  657.  
  658.      gdb -help
  659.  
  660. will display all available options and briefly describe their use
  661. (`gdb -h' is a shorter equivalent).
  662.  
  663.    All options and command line arguments you give are processed in
  664. sequential order.  The order makes a difference when the `-x' option
  665. is used.
  666.  
  667. * Menu:
  668.  
  669. * File Options::                Choosing Files
  670. * Mode Options::                Choosing Modes
  671.  
  672. 
  673. File: gdb.info,  Node: File Options,  Next: Mode Options,  Prev: Starting GDB,  Up: Starting GDB
  674.  
  675. Choosing Files
  676. --------------
  677.  
  678.    As shown above, any arguments other than options specify an
  679. executable file and core file; that is, the first argument
  680. encountered with no associated option flag is equivalent to a `-se'
  681. option, and the second, if any, is equivalent to a `-c' option. 
  682. Many options have both long and short forms; both are shown here. 
  683. The long forms are also recognized if you truncate them, so long as
  684. enough
  685. of the option is present to be unambiguous.  (If you prefer, you can
  686. flag
  687. option arguments with `+' rather than `-', though we illustrate the
  688. more usual convention.)
  689.  
  690. `-symbols=FILE'
  691. `-s FILE'
  692.      Read symbol table from file FILE.
  693.  
  694. `-exec=FILE'
  695. `-e FILE'
  696.      Use file FILE as the executable file to execute when
  697.      appropriate, and for examining pure data in conjunction with a
  698.      core dump.
  699.  
  700. `-se=FILE'
  701.      Read symbol table from file FILE and use it as the executable
  702.      file.
  703.  
  704. `-core=FILE'
  705. `-c FILE'
  706.      Use file FILE as a core dump to examine.
  707.  
  708. `-command=FILE'
  709. `-x FILE'
  710.      Execute GDB commands from file FILE.  *Note Command Files::.
  711.  
  712. `-directory=DIRECTORY'
  713. `-d DIRECTORY'
  714.      Add DIRECTORY to the path to search for source files.
  715.  
  716. 
  717. File: gdb.info,  Node: Mode Options,  Prev: File Options,  Up: Starting GDB
  718.  
  719. Choosing Modes
  720. --------------
  721.  
  722. `-nx'
  723. `-n'
  724.      Do not execute commands from any `.gdbinit' initialization files.
  725.      Normally, the commands in these files are executed after all
  726.      the command options and arguments have been processed.  *Note
  727.      Command Files::.
  728.  
  729. `-quiet'
  730. `-q'
  731.      "Quiet".  Do not print the introductory and copyright messages. 
  732.      These messages are also suppressed in batch mode, or if an
  733.      executable file name is specified on the GDB command line.
  734.  
  735. `-batch'
  736.      Run in batch mode.  Exit with status `0' after processing all
  737.      the command files specified with `-x' (and `.gdbinit', if not
  738.      inhibited).  Exit with nonzero status if an error occurs in
  739.      executing the GDB commands in the command files.
  740.  
  741.      Batch mode may be useful for running GDB as a filter, for
  742.      example to download and run a program on another computer; in
  743.      order to make this more useful, the message
  744.  
  745.           Program exited normally.
  746.  
  747.      (which is ordinarily issued whenever a program running under GDB
  748.      control terminates) is not issued when running in batch mode.
  749.  
  750. `-cd=DIRECTORY'
  751.      Run GDB using DIRECTORY as its working directory, instead of the
  752.      current directory.
  753.  
  754. `-fullname'
  755. `-f'
  756.      Emacs sets this option when it runs GDB as a subprocess.  It
  757.      tells GDB to output the full file name and line number in a
  758.      standard, recognizable fashion each time a stack frame is
  759.      displayed (which includes each time the program stops).  This
  760.      recognizable format looks like two `\032' characters, followed
  761.      by the file name, line number and character position separated
  762.      by colons, and a newline.  The Emacs-to-GDB interface program
  763.      uses the two `\032' characters as a signal to display the
  764.      source code for the frame.
  765.  
  766. `-b BPS'
  767.      Set the line speed (baud rate or bits per second) of any serial
  768.      interface used by GDB for remote debugging.
  769.  
  770. `-tty=DEVICE'
  771.      Run using DEVICE for your program's standard input and output.
  772.  
  773. 
  774. File: gdb.info,  Node: Leaving GDB,  Next: Shell Commands,  Prev: Starting GDB,  Up: Invocation
  775.  
  776. Leaving GDB
  777. ===========
  778.  
  779. `quit'
  780.      To exit GDB, use the `quit' command (abbreviated `q'), or type
  781.      an end-of-file character (usually `C-d').
  782.  
  783.    An interrupt (often `C-c') will not exit from GDB, but rather will
  784. terminate the action of any GDB command that is in progress and
  785. return to GDB command level.  It is safe to type the interrupt
  786. character at any time because GDB does not allow it to take effect
  787. until a time when it is safe.
  788.  
  789.    If you've been using GDB to control an attached process or device,
  790. you can release it with the `detach' command; *note Attach::..
  791.  
  792. 
  793. File: gdb.info,  Node: Shell Commands,  Prev: Leaving GDB,  Up: Invocation
  794.  
  795. Shell Commands
  796. ==============
  797.  
  798.    If you need to execute occasional shell commands during your
  799. debugging session, there's no need to leave or suspend GDB; you can
  800. just use the `shell' command.
  801.  
  802. `shell COMMAND STRING'
  803.      Directs GDB to invoke an inferior shell to execute COMMAND
  804.      STRING.  If it exists, the environment variable `SHELL' is used
  805.      for the name of the shell to run.  Otherwise GDB uses `/bin/sh'.
  806.  
  807.    The utility `make' is often needed in development environments. 
  808. You don't have to use the `shell' command for this purpose in GDB:
  809.  
  810. `make MAKE-ARGS'
  811.      Causes GDB to execute an inferior `make' program with the
  812.      specified arguments.  This is equivalent to `shell make
  813.      MAKE-ARGS'.
  814.  
  815. 
  816. File: gdb.info,  Node: Commands,  Next: Running,  Prev: Invocation,  Up: Top
  817.  
  818. GDB Commands
  819. ************
  820.  
  821. * Menu:
  822.  
  823. * Command Syntax::              Command Syntax
  824. * Help::                        Getting Help
  825.  
  826. 
  827. File: gdb.info,  Node: Command Syntax,  Next: Help,  Prev: Commands,  Up: Commands
  828.  
  829. Command Syntax
  830. ==============
  831.  
  832.    A GDB command is a single line of input.  There is no limit on how
  833. long it can be.  It starts with a command name, which is followed by
  834. arguments
  835. whose meaning depends on the command name.  For example, the command
  836. `step' accepts an argument which is the number of times to step, as
  837. in `step 5'.  You can also use the `step' command with no arguments.
  838. Some command names do not allow any arguments.
  839.  
  840.    GDB command names may always be truncated if that abbreviation is
  841. unambiguous.  Other possible command abbreviations are listed in the
  842. documentation for individual commands.  In some cases, even
  843. ambiguous abbreviations are allowed; for example, `s' is specially
  844. defined as equivalent to `step' even though there are other commands
  845. whose names start with `s'.  You can test abbreviations by using
  846. them as arguments to the `help' command.
  847.  
  848.    A blank line as input to GDB (typing just RET) means to repeat the
  849. previous command. Certain commands (for example, `run') will not
  850. repeat this way; these are commands for which unintentional
  851. repetition might cause trouble and which you are unlikely to want to
  852. repeat.
  853.  
  854.    The `list' and `x' commands, when you repeat them with RET,
  855. construct new arguments rather than repeating exactly as typed. 
  856. This permits easy scanning of source or memory.
  857.  
  858.    GDB can also use RET in another way: to partition lengthy output,
  859. in a way similar to the common utility `more' (*note Screen
  860. Size::.).  Since it's easy to press one RET too many in this
  861. situation, GDB disables command repetition after any command that
  862. generates this sort of display.
  863.  
  864.    A line of input starting with `#' is a comment; it does nothing. 
  865. This is useful mainly in command files (*Note Command Files::).
  866.  
  867. 
  868. File: gdb.info,  Node: Help,  Prev: Command Syntax,  Up: Commands
  869.  
  870. Getting Help
  871. ============
  872.  
  873.    You can always ask GDB itself for information on its commands,
  874. using the command `help'.
  875.  
  876. `help'
  877. `h'
  878.      You can use `help' (abbreviated `h') with no arguments to
  879.      display a short list of named classes of commands:
  880.  
  881.           (gdb) help
  882.           List of classes of commands:
  883.           
  884.           running -- Running the program
  885.           stack -- Examining the stack
  886.           data -- Examining data
  887.           breakpoints -- Making program stop at certain points
  888.           files -- Specifying and examining files
  889.           status -- Status inquiries
  890.           support -- Support facilities
  891.           user-defined -- User-defined commands
  892.           aliases -- Aliases of other commands
  893.           obscure -- Obscure features
  894.           
  895.           Type "help" followed by a class name for a list of commands in that class.
  896.           Type "help" followed by command name for full documentation.
  897.           Command name abbreviations are allowed if unambiguous.
  898.           (gdb)
  899.  
  900. `help CLASS'
  901.      Using one of the general help classes as an argument, you can
  902.      get a list of the individual commands in that class.  For
  903.      example, here is the help display for the class `status':
  904.  
  905.           (gdb) help status
  906.           Status inquiries.
  907.           
  908.           List of commands:
  909.           
  910.           show -- Generic command for showing things set with "set"
  911.           info -- Generic command for printing status
  912.           
  913.           Type "help" followed by command name for full documentation.
  914.           Command name abbreviations are allowed if unambiguous.
  915.           (gdb)
  916.  
  917. `help COMMAND'
  918.      With a command name as `help' argument, GDB will display a short
  919.      paragraph on how to use that command.
  920.  
  921.    In addition to `help', you can use the GDB commands `info' and
  922. `show' to inquire about the state of your program, or the state of
  923. GDB itself.  Each command supports many topics of inquiry; this
  924. manual introduces each of them in the appropriate context.  The
  925. listings under `info' and under `show' in the Index point to all the
  926. sub-commands.
  927.  
  928. `info'
  929.      This command (abbreviated `i') is for describing the state of
  930.      your program; for example, it can list the arguments given to
  931.      your program (`info args'), the registers currently in use
  932.      (`info registers'), or the breakpoints you've set (`info
  933.      breakpoints').  You can get a complete list of the `info'
  934.      sub-commands with `help info'.
  935.  
  936. `show'
  937.      In contrast, `show' is for describing the state of GDB itself. 
  938.      You can change most of the things you can `show', by using the
  939.      related command `set'; for example, you can control what number
  940.      system is used for displays with `set radix', or simply inquire
  941.      which is currently in use with `show radix'.
  942.  
  943.      To display all the settable parameters and their current values,
  944.      you can use `show' with no arguments; you may also use `info
  945.      set'.  Both commands produce the same display.
  946.  
  947.    Here are three miscellaneous `show' subcommands, all of which are
  948. exceptional in lacking corresponding `set' commands:
  949.  
  950. `show version'
  951.      Show what version of GDB is running.  You should include this
  952.      information in GDB bug-reports.  If multiple versions of GDB
  953.      are in use at your site, you may occasionally want to make sure
  954.      what version of GDB you're running; as GDB evolves, new
  955.      commands are introduced, and old ones may wither away.  The
  956.      version number is also announced when you start GDB with no
  957.      arguments.
  958.  
  959. `show copying'
  960.      Display information about permission for copying GDB.
  961.  
  962. `show warranty'
  963.      Display the GNU "NO WARRANTY" statement.
  964.  
  965. 
  966. File: gdb.info,  Node: Running,  Next: Stopping,  Prev: Commands,  Up: Top
  967.  
  968. Running Programs Under GDB
  969. **************************
  970.  
  971. * Menu:
  972.  
  973. * Compilation::                 Compiling for Debugging
  974. * Starting::                    Starting your Program
  975. * Arguments::                   Your Program's Arguments
  976. * Environment::                 Your Program's Environment
  977. * Working Directory::           Your Program's Working Directory
  978. * Input/Output::                Your Program's Input and Output
  979. * Attach::                      Debugging an Already-Running Process
  980. * Kill Process::                Killing the Child Process
  981.  
  982. 
  983. File: gdb.info,  Node: Compilation,  Next: Starting,  Prev: Running,  Up: Running
  984.  
  985. Compiling for Debugging
  986. =======================
  987.  
  988.    In order to debug a program effectively, you need to generate
  989. debugging information when you compile it.  This debugging
  990. information is stored in the object file; it describes the data type
  991. of each variable or function and the correspondence between source
  992. line numbers and addresses in the executable code.
  993.  
  994.    To request debugging information, specify the `-g' option when you
  995. run the compiler.
  996.  
  997.    Many C compilers are unable to handle the `-g' and `-O' options
  998. together.  Using those compilers, you cannot generate optimized
  999. executables containing debugging information.
  1000.  
  1001.    The GNU C compiler supports `-g' with or without `-O', making it
  1002. possible to debug optimized code.  We recommend that you *always*
  1003. use `-g' whenever you compile a program.  You may think the program
  1004. is correct, but there's no sense in pushing your luck.
  1005.  
  1006.    Some things do not work as well with `-g -O' as with just `-g',
  1007. particularly on machines with instruction scheduling.  If in doubt,
  1008. recompile with `-g' alone, and if this fixes the problem, please
  1009. report it as a bug (including a test case!).
  1010.  
  1011.    Older versions of the GNU C compiler permitted a variant option
  1012. `-gg' for debugging information.  GDB no longer supports this
  1013. format; if your GNU C compiler has this option, do not use it.
  1014.  
  1015. 
  1016. File: gdb.info,  Node: Starting,  Next: Arguments,  Prev: Compilation,  Up: Running
  1017.  
  1018. Starting your Program
  1019. =====================
  1020.  
  1021. `run'
  1022. `r'
  1023.      Use the `run' command to start your program under GDB.  You must
  1024.      first specify the program name (except on VxWorks) with an
  1025.      argument to GDB (*note Invocation::.), or using the `file' or
  1026.      `exec-file' command (*note Files::.).
  1027.  
  1028.    On targets that support processes, `run' creates an inferior
  1029. process and makes that process run your program.  On other targets,
  1030. `run' jumps to the start of the program.
  1031.  
  1032.    The execution of a program is affected by certain information it
  1033. receives from its superior.  GDB provides ways to specify this
  1034. information, which you must do before starting the program.  (You
  1035. can change it after starting the program, but such changes will only
  1036. affect the program the next time you start it.)  This information
  1037. may be divided into four categories:
  1038.  
  1039. The arguments.
  1040.      You specify the arguments to give your program as the arguments
  1041.      of the `run' command.  If a shell is available on your target,
  1042.      the shell is used to pass the arguments, so that you may use
  1043.      normal conventions (such as wildcard expansion or variable
  1044.      substitution) in describing the arguments.  In Unix systems,
  1045.      you can control which shell is used with the `SHELL'
  1046.      environment variable. *Note Arguments::.
  1047.  
  1048. The environment.
  1049.      Your program normally inherits its environment from GDB, but you
  1050.      can use the GDB commands `set environment' and `unset
  1051.      environment' to change parts of the environment that will be
  1052.      given to the program.  *Note Environment::.
  1053.  
  1054. The working directory.
  1055.      Your program inherits its working directory from GDB.  You can
  1056.      set GDB's working directory with the `cd' command in GDB. 
  1057.      *Note Working Directory::.
  1058.  
  1059. The standard input and output.
  1060.      Your program normally uses the same device for standard input
  1061.      and standard output as GDB is using.  You can redirect input
  1062.      and output in the `run' command line, or you can use the `tty'
  1063.      command to set a different device for your program.  *Note
  1064.      Input/Output::.
  1065.  
  1066.      *Warning:* While input and output redirection work, you can't
  1067.      use pipes to pass the output of the program you're debugging to
  1068.      another program; if you attempt this, GDB is likely to wind up
  1069.      debugging the wrong program.
  1070.  
  1071.    When you issue the `run' command, your program begins to execute
  1072. immediately.  *Note Stopping::, for discussion of how to arrange for
  1073. your program to stop.  Once your program has been started by the
  1074. `run' command (and then stopped), you may evaluate expressions that
  1075. involve calls to functions in the inferior, using the `print' or
  1076. `call' commands.  *Note Data::.
  1077.  
  1078.    If the modification time of your symbol file has changed since the
  1079. last time GDB read its symbols, GDB will discard its symbol table
  1080. and re-read it.  In this process, it tries to retain your current
  1081. breakpoints.
  1082.  
  1083. 
  1084. File: gdb.info,  Node: Arguments,  Next: Environment,  Prev: Starting,  Up: Running
  1085.  
  1086. Your Program's Arguments
  1087. ========================
  1088.  
  1089.    The arguments to your program can be specified by the arguments of
  1090. the `run' command.  They are passed to a shell, which expands
  1091. wildcard characters and performs redirection of I/O, and thence to
  1092. the program.  GDB uses the shell indicated by your environment
  1093. variable
  1094. `SHELL' if it exists; otherwise, GDB uses `/bin/sh'.
  1095.  
  1096.    `run' with no arguments uses the same arguments used by the
  1097. previous `run', or those set by the `set args' command.
  1098.  
  1099. `set args'
  1100.      Specify the arguments to be used the next time your program is
  1101.      run.  If `set args' has no arguments, `run' will execute your
  1102.      program with no arguments.  Once you have run your program with
  1103.      arguments,  using `set args' before the next `run' is the only
  1104.      way to run it again without arguments.
  1105.  
  1106. `show args'
  1107.      Show the arguments to give your program when it is started.
  1108.  
  1109. 
  1110. File: gdb.info,  Node: Environment,  Next: Working Directory,  Prev: Arguments,  Up: Running
  1111.  
  1112. Your Program's Environment
  1113. ==========================
  1114.  
  1115.    The "environment" consists of a set of environment variables and
  1116. their values.  Environment variables conventionally record such
  1117. things as your user name, your home directory, your terminal type,
  1118. and your search path for programs to run.  Usually you set up
  1119. environment variables with the shell and they are inherited by all
  1120. the other programs you run.  When debugging, it can be useful to try
  1121. running the program with a modified environment without having to
  1122. start GDB over again.
  1123.  
  1124. `path DIRECTORY'
  1125.      Add DIRECTORY to the front of the `PATH' environment variable
  1126.      (the search path for executables), for both GDB and your program.
  1127.      You may specify several directory names, separated by `:' or
  1128.      whitespace.  If DIRECTORY is already in the path, it is moved
  1129.      to the front, so it will be searched sooner.
  1130.  
  1131.      You can use the string `$cwd' to refer to whatever is the
  1132.      current working directory at the time GDB searches the path. 
  1133.      If you use `.' instead, it refers to the directory where you
  1134.      executed the `path' command.  GDB fills in the current path
  1135.      where needed in the DIRECTORY argument, before adding it to the
  1136.      search path.
  1137.  
  1138. `show paths'
  1139.      Display the list of search paths for executables (the `PATH'
  1140.      environment variable).
  1141.  
  1142. `show environment [VARNAME]'
  1143.      Print the value of environment variable VARNAME to be given to
  1144.      your program when it starts.  If you don't supply VARNAME, 
  1145.      print the names and values of all environment variables to be
  1146.      given to your program.  You can abbreviate `environment' as
  1147.      `env'.
  1148.  
  1149. `set environment VARNAME [=] VALUE'
  1150.      Sets environment variable VARNAME to VALUE.  The value changes
  1151.      for your program only, not for GDB itself.  VALUE may be any
  1152.      string; the values of environment variables are just strings,
  1153.      and any interpretation is supplied by your program itself.  The
  1154.     
  1155.      VALUE parameter is optional; if it is eliminated, the variable
  1156.      is set to a null value.
  1157.  
  1158.      For example, this command:
  1159.  
  1160.           set env USER = foo
  1161.  
  1162.      tells a Unix program, when subsequently run, that its user is
  1163.      named `foo'.  (The spaces around `=' are used for clarity here;
  1164.      they are not actually required.)
  1165.  
  1166. `unset environment VARNAME'
  1167.      Remove variable VARNAME from the environment to be passed to
  1168.      your program.  This is different from `set env VARNAME =';
  1169.      `unset environment' removes the variable from the environment,
  1170.      rather than assigning it an empty value.
  1171.  
  1172. 
  1173. File: gdb.info,  Node: Working Directory,  Next: Input/Output,  Prev: Environment,  Up: Running
  1174.  
  1175. Your Program's Working Directory
  1176. ================================
  1177.  
  1178.    Each time you start your program with `run', it inherits its
  1179. working directory from the current working directory of GDB.  GDB's
  1180. working directory is initially whatever it inherited from its parent
  1181. process (typically the shell), but you can specify a new working
  1182. directory in GDB with the `cd' command.
  1183.  
  1184.    The GDB working directory also serves as a default for the
  1185. commands that specify files for GDB to operate on.  *Note Files::.
  1186.  
  1187. `cd DIRECTORY'
  1188.      Set GDB's working directory to DIRECTORY.
  1189.  
  1190. `pwd'
  1191.      Print GDB's working directory.
  1192.  
  1193. 
  1194. File: gdb.info,  Node: Input/Output,  Next: Attach,  Prev: Working Directory,  Up: Running
  1195.  
  1196. Your Program's Input and Output
  1197. ===============================
  1198.  
  1199.    By default, the program you run under GDB does input and output to
  1200. the same terminal that GDB uses.  GDB switches the terminal to its
  1201. own terminal modes to interact with you, but it records the terminal
  1202. modes your program was using and switches back to them when you
  1203. continue running your program.
  1204.  
  1205. `info terminal'
  1206.      Displays GDB's recorded information about the terminal modes
  1207.      your program is using.
  1208.  
  1209.    You can redirect the program's input and/or output using shell
  1210. redirection with the `run' command.  For example,
  1211.  
  1212.      run > outfile
  1213.  
  1214. starts the program, diverting its output to the file `outfile'.
  1215.  
  1216.    Another way to specify where the program should do input and
  1217. output is with the `tty' command.  This command accepts a file name
  1218. as argument, and causes this file to be the default for future `run'
  1219. commands.  It also resets the controlling terminal for the child
  1220. process, for future `run' commands.  For example,
  1221.  
  1222.      tty /dev/ttyb
  1223.  
  1224. directs that processes started with subsequent `run' commands default
  1225. to do input and output on the terminal `/dev/ttyb' and have that as
  1226. their controlling terminal.
  1227.  
  1228.    An explicit redirection in `run' overrides the `tty' command's
  1229. effect on the input/output device, but not its effect on the
  1230. controlling terminal.
  1231.  
  1232.    When you use the `tty' command or redirect input in the `run'
  1233. command, only the input *for your program* is affected.  The input
  1234. for GDB still comes from your terminal.
  1235.  
  1236. 
  1237. File: gdb.info,  Node: Attach,  Next: Kill Process,  Prev: Input/Output,  Up: Running
  1238.  
  1239. Debugging an Already-Running Process
  1240. ====================================
  1241.  
  1242. `attach PROCESS-ID'
  1243.      This command attaches to a running process--one that was started
  1244.      outside GDB.  (`info files' will show your active targets.) 
  1245.      The command takes as argument a process ID.  The usual way to
  1246.      find out the process-id of a Unix process is with the `ps'
  1247.      utility, or with the `jobs -l' shell command.
  1248.  
  1249.      `attach' will not repeat if you press RET a second time after
  1250.      executing the command.
  1251.  
  1252.    To use `attach', you must be debugging in an environment which
  1253. supports processes.  You must also have permission to send the
  1254. process a signal, and it must have the same effective user ID as the
  1255. GDB process.
  1256.  
  1257.    When using `attach', you should first use the `file' command to
  1258. specify the program running in the process and load its symbol table.
  1259. *Note Files::.
  1260.  
  1261.    The first thing GDB does after arranging to debug the specified
  1262. process is to stop it.  You can examine and modify an attached
  1263. process with all the GDB commands that are ordinarily available when
  1264. you start processes with `run'.  You can insert breakpoints; you can
  1265. step and continue; you can modify storage.  If you would rather the
  1266. process continue running, you may use the `continue' command after
  1267. attaching GDB to the process.
  1268.  
  1269. `detach'
  1270.      When you have finished debugging the attached process, you can
  1271.      use the `detach' command to release it from GDB's control. 
  1272.      Detaching the process continues its execution.  After the
  1273.      `detach' command, that process and GDB become completely
  1274.      independent once more, and you are ready to `attach' another
  1275.      process or start one with `run'.  `detach' will not repeat if
  1276.      you press RET again after executing the command.
  1277.  
  1278.    If you exit GDB or use the `run' command while you have an
  1279. attached process, you kill that process.  By default, you will be
  1280. asked
  1281. for confirmation if you try to do either of these things; you can
  1282. control whether or not you need to confirm by using the `set
  1283. confirm' command (*note Messages/Warnings::.).
  1284.  
  1285. 
  1286. File: gdb.info,  Node: Kill Process,  Prev: Attach,  Up: Running
  1287.  
  1288. Killing the Child Process
  1289. =========================
  1290.  
  1291. `kill'
  1292.      Kill the child process in which your program is running under GDB.
  1293.  
  1294.    This command is useful if you wish to debug a core dump instead of
  1295. a
  1296. running process.  GDB ignores any core dump file while your program
  1297. is running.
  1298.  
  1299.    On some operating systems, a program can't be executed outside GDB
  1300. while
  1301. you have breakpoints set on it inside GDB.  You can use the `kill'
  1302. command in this situation to permit running the program outside the
  1303. debugger.
  1304.  
  1305.    The `kill' command is also useful if you wish to recompile and
  1306. relink the program, since on many systems it is impossible to modify
  1307. an executable file while it is running in a process.  In this case,
  1308. when you next type `run', GDB will notice that the file has changed,
  1309. and will re-read the symbol table (while trying to preserve your
  1310. current breakpoint settings).
  1311.  
  1312. 
  1313. File: gdb.info,  Node: Stopping,  Next: Stack,  Prev: Running,  Up: Top
  1314.  
  1315. Stopping and Continuing
  1316. ***********************
  1317.  
  1318.    The principal purpose of using a debugger is so that you can stop
  1319. your program before it terminates; or so that, if the program runs
  1320. into trouble, you can investigate and find out why.
  1321.  
  1322.    Inside GDB, your program may stop for any of several reasons, such
  1323. as a signal, a breakpoint, or reaching a new line after a GDB
  1324. command such as `step'.  You may then examine and change variables,
  1325. set
  1326. new breakpoints or remove old ones, and then continue execution. 
  1327. Usually, the messages shown by GDB provide ample explanation of the
  1328. status of your program--but you can also explicitly request this
  1329. information at any time.
  1330.  
  1331. `info program'
  1332.      Display information about the status of your program: whether it
  1333.      is running or not, what process it is, and why it stopped.
  1334.  
  1335. * Menu:
  1336.  
  1337. * Breakpoints::                 Breakpoints, Watchpoints, and Exceptions
  1338. * Continuing and Stepping::     Resuming Execution
  1339. * Signals::                     Signals
  1340.  
  1341.